﻿Imports System

Module Reflectionhelpers
   Friend Sub SetPropertyOnObject(ByVal PropName As String, ByVal obj As Object, ByVal Value As Object)
      Dim pi As Reflection.PropertyInfo
      pi = obj.GetType.GetProperty(PropName, _
                                   Reflection.BindingFlags.SetProperty Or _
                                   Reflection.BindingFlags.Instance Or _
                                   Reflection.BindingFlags.Public)
      pi.SetValue(obj, Value, Nothing)
   End Sub

   Friend Function GetPropPublic(ByVal PropName As String, ByVal obj As Object) As Object
      Dim pi As Reflection.PropertyInfo
      pi = obj.GetType.GetProperty(PropName, _
                                   Reflection.BindingFlags.Instance Or _
                                   Reflection.BindingFlags.Public)
      Return pi.GetValue(obj, Nothing)
   End Function

   Friend Function GetPropNonPublic(ByVal PropName As String, ByVal obj As Object) As Object
      Dim pi As Reflection.PropertyInfo
      pi = obj.GetType.GetProperty(PropName, _
                                   Reflection.BindingFlags.Instance Or _
                                   Reflection.BindingFlags.NonPublic)
      Return pi.GetValue(obj, Nothing)
   End Function



   Friend Function GetStaticMethod(ByVal obj As Object, ByVal Method As String) As Reflection.MethodInfo
      Return obj.GetType.GetMethod(Method, _
                                   Reflection.BindingFlags.Static Or _
                                   Reflection.BindingFlags.NonPublic)
   End Function
End Module
